package com.justnow.offer;

import java.util.Scanner;

/**
 * @author justnow
 * Created on 2020-09-08
 * Description
 */
public class Xiaomi01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] array = str.split(" ");
        for (String s : array) {
            System.out.println(charge(s));
        }

/*
        System.out.println('a' - '0'); //49
        System.out.println('z' - '0'); //74
        System.out.println('A' - '0'); //17
        System.out.println('Z' - '0'); //42
*/
    }

    public static int charge(String str) {
        if (str.length() < 8 || str.length() > 120)
            return 1;
        //全是数字
        char[] chars = str.toCharArray();
        boolean hasNumber = false;
        boolean hasBigChar = false;
        boolean hasSmallchar = false;
        boolean hasOther = false;
        boolean allflag = false;
        for (char aChar : chars) {
            if (hasBigChar && hasSmallchar && hasNumber && hasOther) {
                allflag = true;
                break;
            }
            int temp = aChar - '0';
            if (temp >= 0 && temp <= 9)
                hasNumber = true;
            else if (temp >= 17 && temp <= 42)
                hasBigChar = true;
            else if (temp >= 49 && temp <= 74)
                hasSmallchar = true;
            else
                hasOther = true;
        }

        if (allflag)
            return 0;
        return 2;
    }
}
